load FaceNonFace
% Split the dataset into training and testing sets
split_ratio = 0.8; % 80% for training, 20% for testing
nbr_total_examples = size(X, 2);
nbr_train_examples = round(split_ratio * nbr_total_examples);
X_train = X(:, 1:nbr_train_examples);
Y_train = Y(:, 1:nbr_train_examples);
X_test = X(:, nbr_train_examples+1:end);
Y_test = Y(:, nbr_train_examples+1:end);

% Train the CNN model
net = trainSimpleCNN(X_train, Y_train);

% Predict on the training and testing sets
predictions_train = predictSimpleCNN(net, X_train);
predictions_test = predictSimpleCNN(net, X_test);

% Compute the error rates
pred_train_diff = predictions_train - Y_train;
pred_test_diff = predictions_test - Y_test;
err_rate_train = nnz(pred_train_diff) / length(Y_train);
err_rate_test = nnz(pred_test_diff) / length(Y_test);

% Display the error rates
disp(['Training error rate: ', num2str(err_rate_train)]);
disp(['Testing error rate: ', num2str(err_rate_test)]);
